Xbasic

Array resize Method

Syntax

V <array>.resize(size as N [,dimension as N])

Arguments

sizeNumeric

The new number of elements in the array.

dimensionNumeric

Default = 1. The dimension of the array to resize.

Description

Resize an array, keeping its components intact.

Discussion

The <array>.resize() method increases the size of an array, without losing any of the existing data, as the REDIM command would.

Example

dim fruit[3,2] as C
fruit[1,1] = "Apple"
fruit[2,1] = "Banana"
fruit[3,1] = "Cherry"
fruit.resize(4,1)

? fruit
= [1,1] = "Apple"
[1,2] = ""
[2,1] = "Banana"
[2,2] = ""
[3,1] = "Cherry"
[3,2] = ""
[4,1] = ""
[4,2] = ""

fruit.resize(3,2)

? fruit
= [1,1] = "Apple"
[1,2] = ""
[1,3] = ""
[2,1] = "Banana"
[2,2] = ""
[2,3] = ""
[3,1] = "Cherry"
[3,2] = ""
[3,3] = ""
[4,1] = ""
[4,2] = ""
[4,3] = ""